package com.jry.demo.controller;

import com.jry.common.core.constant.HttpStatus;
import com.jry.common.core.web.domain.AjaxResult;
import com.jry.demo.domain.DemoVo;
import com.jry.demo.service.DemoTestService;
import com.jry.system.api.model.LoginUser;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * Copyright (C), 2017-2025, SuZhou JRY Technologies Co., Ltd. All rights reserved.
 * <http://jrycn.cn/>
 *
 * @FileName : DemoTestController
 * @Author : zhangsuhang
 * @Date : 2022/3/3 14:40
 * @DESCRIPTION :
 * @History : DATE       NAME       DESC
 */
@RestController
@RequestMapping("demo")
public class DemoTestController {

    @Resource
    private DemoTestService demoTestService;

    @PostMapping("add")
    public AjaxResult add(@RequestBody DemoVo demoVo) {
        Map<String, Object> res = demoTestService.add(demoVo);
        int code = (int) res.get(AjaxResult.CODE_TAG);
        return code == HttpStatus.SUCCESS ? AjaxResult.success() : AjaxResult.error((String) res.get(AjaxResult.MSG_TAG));
    }

    @RequestMapping("list")
    public AjaxResult getList(DemoVo demoVo) {
        return AjaxResult.success(demoTestService.getList(demoVo));
    }

    @RequestMapping("getSystemUser")
    public AjaxResult getSystemUser(@RequestParam("userName") String userName) {
        LoginUser systemUser = demoTestService.getSystemUser(userName);
        return AjaxResult.success(systemUser);
    }
}
